import _regeneratorRuntime from "@babel/runtime/regenerator";
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";

/**
 * staticTextServiceOrg.js
 * @date 2018-12-25

 */
import request from 'utils/request';
import { CPAAS_PLATFORM } from 'utils/config';
import { parseParameters } from 'utils/utils';
/**
 * 新增静态文本
 * @param {number} organizationId
 * @param {object} record
 * @return {Promise<Response>}
 */

export function staticTextCreateOne(_x, _x2) {
  return _staticTextCreateOne.apply(this, arguments);
}
/**
 * 批量删除静态文本
 * @param {number} organizationId
 * @param {object[]} records
 * @return {Promise<Response>}
 */

function _staticTextCreateOne() {
  _staticTextCreateOne = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(organizationId, record) {
    return _regeneratorRuntime.wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            return _context.abrupt("return", request("".concat(CPAAS_PLATFORM, "/v1/").concat(organizationId, "/static-texts"), {
              method: 'POST',
              body: record
            }));

          case 1:
          case "end":
            return _context.stop();
        }
      }
    }, _callee);
  }));
  return _staticTextCreateOne.apply(this, arguments);
}

export function staticTextRemoveList(_x3, _x4) {
  return _staticTextRemoveList.apply(this, arguments);
}
/**
 * 修改静态文本
 * @param {number} organizationId
 * @param {object} record
 * @return {Promise<Response>}
 */

function _staticTextRemoveList() {
  _staticTextRemoveList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(organizationId, records) {
    return _regeneratorRuntime.wrap(function _callee2$(_context2) {
      while (1) {
        switch (_context2.prev = _context2.next) {
          case 0:
            return _context2.abrupt("return", request("".concat(CPAAS_PLATFORM, "/v1/").concat(organizationId, "/static-texts"), {
              method: 'DELETE',
              body: records
            }));

          case 1:
          case "end":
            return _context2.stop();
        }
      }
    }, _callee2);
  }));
  return _staticTextRemoveList.apply(this, arguments);
}

export function staticTextUpdateOne(_x5, _x6) {
  return _staticTextUpdateOne.apply(this, arguments);
}
/**
 * 分页查询静态文本分页
 * @param {number} organizationId
 * @param {number} textId - 静态文本id
 * @param {object} params
 * @return {Promise<Response>}
 */

function _staticTextUpdateOne() {
  _staticTextUpdateOne = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(organizationId, record) {
    return _regeneratorRuntime.wrap(function _callee3$(_context3) {
      while (1) {
        switch (_context3.prev = _context3.next) {
          case 0:
            return _context3.abrupt("return", request("".concat(CPAAS_PLATFORM, "/v1/").concat(organizationId, "/static-texts"), {
              method: 'PUT',
              body: record
            }));

          case 1:
          case "end":
            return _context3.stop();
        }
      }
    }, _callee3);
  }));
  return _staticTextUpdateOne.apply(this, arguments);
}

export function staticTextFetchOne(_x7, _x8, _x9) {
  return _staticTextFetchOne.apply(this, arguments);
}
/**
 * 分页查询静态文本分页
 * @param {number} organizationId
 * @param {object} params
 * @return {Promise<Response>}
 */

function _staticTextFetchOne() {
  _staticTextFetchOne = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(organizationId, textId, params) {
    return _regeneratorRuntime.wrap(function _callee4$(_context4) {
      while (1) {
        switch (_context4.prev = _context4.next) {
          case 0:
            return _context4.abrupt("return", request("".concat(CPAAS_PLATFORM, "/v1/").concat(organizationId, "/static-texts/details/").concat(textId), {
              method: 'GET',
              query: params
            }));

          case 1:
          case "end":
            return _context4.stop();
        }
      }
    }, _callee4);
  }));
  return _staticTextFetchOne.apply(this, arguments);
}

export function staticTextFetchList(_x10, _x11) {
  return _staticTextFetchList.apply(this, arguments);
}

function _staticTextFetchList() {
  _staticTextFetchList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(organizationId, params) {
    var parsedParams;
    return _regeneratorRuntime.wrap(function _callee5$(_context5) {
      while (1) {
        switch (_context5.prev = _context5.next) {
          case 0:
            parsedParams = parseParameters(params);
            return _context5.abrupt("return", request("".concat(CPAAS_PLATFORM, "/v1/").concat(organizationId, "/static-texts"), {
              method: 'GET',
              query: parsedParams
            }));

          case 2:
          case "end":
            return _context5.stop();
        }
      }
    }, _callee5);
  }));
  return _staticTextFetchList.apply(this, arguments);
}